import sun.util.resources.cldr.es.TimeZoneNames_es_419;

import java.util.Arrays;
import java.util.Random;

public class Test {
    public static void teatInsertSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        TestSort testSort = new TestSort();
        testSort.insort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("直接插入排序耗时"+(endTime-startTime));
    }
    public static void teatShellSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        TestSort testSort = new TestSort();
        testSort.shell(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时"+(endTime-startTime));
    }
    public static void teatSelectlSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        TestSort testSort = new TestSort();
        testSort.selectSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("选择排序耗时"+(endTime-startTime));
    }
    public static void teatHeaplSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        TestSort testSort = new TestSort();
        testSort.heapSort1(array);
        long endTime = System.currentTimeMillis();
        System.out.println("堆排序耗时"+(endTime-startTime));
    }
    public static void teatBubblelSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        TestSort testSort = new TestSort();
        testSort.bubbleSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("冒泡排序耗时"+(endTime-startTime));
    }
    public static void teatQuicklSort(int[] array){
        array = Arrays.copyOf(array,array.length);
        long startTime=System.currentTimeMillis();
        TestSort testSort = new TestSort();
        testSort.quickSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时"+(endTime-startTime));
    }
    public static void initArray1(int[] array){
        for (int i = 0; i < array.length; i++) {
            array[i]=i;
        }
    }
    public static void initArray2(int[] array){
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i]=random.nextInt(10_0000);
        }
    }
    public static void main1(String[] args) {
        int[] array = new  int[10_0000];
        initArray1(array);
//        initArray2(array);
        teatInsertSort(array);
        teatShellSort(array);
        teatSelectlSort(array);
        teatHeaplSort(array);
        teatBubblelSort(array);
        teatQuicklSort(array);
    }
    public static void main(String[] args) {
        int[] array={15,2,4,88,77,66,88,55,44};
        TestSort testSort = new TestSort();
//        testSort.bubbleSort(array);
        testSort.quickSort2(array);
        for (int i = 0; i <array.length; i++) {
            System.out.println(array[i]);
        }

    }
}
